package com.nagat.http.xml;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 * @author yasenagat  E-mail: yasenagat@163.com
 * @version 创建时间：2012-4-5 下午2:51:00
 * 类说明
 */
public class XmlClient {
	
	public static void main(String[] args) {
		
		
		try {
			
			String xml = "<?xml version='1.0' encoding='utf-8'?>" +
					"<message>" +
					"<username>ayli</username>" +
					"<password>liya</password>" +
					"</message>";
			
			HttpClient client = new DefaultHttpClient();
			
			HttpPost post = new HttpPost("http://localhost:9988");
			
			StringEntity entity = new StringEntity(xml, "text/html", "utf-8");
			
			post.setEntity(entity);
			
			ResponseHandler<String> response = new BasicResponseHandler();
			
			String ret = client.execute(post, response);
			
			System.out.println(ret);
		} catch (Exception e) {
			e.printStackTrace();
		} 
		
		
	}

}
